package top.lilele.adminSystem.web;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import top.lilele.adminSystem.service.AdminFilePartService;
import top.lilele.adminSystem.utils.BaseResponse;
import top.lilele.adminSystem.utils.ResponseCodeEnum;

import javax.annotation.Resource;

/**
 * @author lilele
 */
@RestController
@RequestMapping(value = "filePart")
public class AdminFilePartController {
    @Resource
    AdminFilePartService adminFilePartService;

    @PostMapping(value = "upload")
    public BaseResponse upload(@RequestParam("generateUploadId") String generateUploadId,
                               @RequestParam("chunkTotal") Integer chunkTotal,
                               @RequestParam("md5") String md5,
                               @RequestParam("currentChunk") Integer currentChunk,
                               @RequestParam("file") MultipartFile multipartFile,
                               @RequestParam(value = "finalMd5", required = false) String finalMd5,
                               @RequestParam(value = "contentType",required = false) String contentType,
                               @RequestParam(value = "originFileName",required = false) String originFileName) {
        adminFilePartService.upload(generateUploadId, chunkTotal, currentChunk, md5, multipartFile, finalMd5, contentType, originFileName);
        return BaseResponse.info(ResponseCodeEnum.Success, null);
    }
}
